<html>
<head><meta charset="utf-8"><title>calling method of lang item trait · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/calling.20method.20of.20lang.20item.20trait.html">calling method of lang item trait</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="234976184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/calling%20method%20of%20lang%20item%20trait/near/234976184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/calling.20method.20of.20lang.20item.20trait.html#234976184">(Apr 17 2021 at 09:47)</a>:</h4>
<p>Is it possible to given <code>T: Termination</code> get the <code>Instance</code> corresponding to <code>&lt;T as Termination&gt;::report</code>? I can get the <code>DefId</code> of <code>Termination</code> as it is a lang item, but how do I get to a concrete <code>Instance</code> of <code>report</code> for a type <code>T</code>?</p>



<a name="234976271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/calling%20method%20of%20lang%20item%20trait/near/234976271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/calling.20method.20of.20lang.20item.20trait.html#234976271">(Apr 17 2021 at 09:49)</a>:</h4>
<p>The jit mode of cg_clif needs to avoid <code>#[lang = "start"]</code> as it does a lot of things that have already been done by the libstd of the host rustc process. I do want to support <code>fn main() -&gt; Result&lt;(), E&gt;</code> though.</p>



<a name="235018719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/calling%20method%20of%20lang%20item%20trait/near/235018719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/calling.20method.20of.20lang.20item.20trait.html#235018719">(Apr 17 2021 at 21:09)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> Try <code>Instance::resolve</code></p>



<a name="235018993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/calling%20method%20of%20lang%20item%20trait/near/235018993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/calling.20method.20of.20lang.20item.20trait.html#235018993">(Apr 17 2021 at 21:10)</a>:</h4>
<p>That requires the <code>DefId</code> of the <code>report</code> method. How do I get this from the <code>Termination</code> trait <code>DefId</code>?</p>



<a name="235023091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/calling%20method%20of%20lang%20item%20trait/near/235023091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/calling.20method.20of.20lang.20item.20trait.html#235023091">(Apr 17 2021 at 22:17)</a>:</h4>
<p>You can mark the method as a lang item</p>



<a name="235023096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/calling%20method%20of%20lang%20item%20trait/near/235023096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/calling.20method.20of.20lang.20item.20trait.html#235023096">(Apr 17 2021 at 22:17)</a>:</h4>
<p>or iterate over the associated items</p>



<a name="235023143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/calling%20method%20of%20lang%20item%20trait/near/235023143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/calling.20method.20of.20lang.20item.20trait.html#235023143">(Apr 17 2021 at 22:18)</a>:</h4>
<p>See <code>fn_once_output</code> for an example of doing that</p>



<a name="235057153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/calling%20method%20of%20lang%20item%20trait/near/235057153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/calling.20method.20of.20lang.20item.20trait.html#235057153">(Apr 18 2021 at 08:58)</a>:</h4>
<p>Thanks. Using <code>tcx.associated_items</code> worked.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>